<?php
/* -----------------------------------------------------------------
 * 	$Id: cseo_logo.php 420 2013-06-19 18:04:39Z akausch $
 * 	Copyright (c) 2011-2021 commerce:SEO by Webdesign Erfurt
 * 	http://www.commerce-seo.de
 * ------------------------------------------------------------------
 * 	based on:
 * 	(c) 2000-2001 The Exchange Project  (earlier name of osCommerce)
 * 	(c) 2002-2003 osCommerce - www.oscommerce.com
 * 	(c) 2003     nextcommerce - www.nextcommerce.org
 * 	(c) 2005     xt:Commerce - www.xt-commerce.com
 * 	Released under the GNU General Public License
 * --------------------------------------------------------------- */
require('includes/application_top.php');

$pdf_query = xtc_db_fetch_array(xtc_db_query("SELECT * FROM orders_pdf_profile WHERE type = 'layout' AND pdf_key = 'LAYOUT_LOGO_FILE';"));

if ($_GET['action']) {
    switch ($_GET['action']) {
        case 'insert_logo':
			$logo_image = xtc_try_upload('logo_image', DIR_FS_CATALOG . 'cache/');
			if ($logo_image->filename == 'logo.png') {
				rename(DIR_FS_CATALOG . 'cache/' . $logo_image->filename, DIR_FS_CATALOG . 'templates/' . CURRENT_TEMPLATE . '/img/' . $logo_image->filename);
				@unlink(DIR_FS_CATALOG . 'cache/' . $logo_image->filename);
				$messageStack->add_session(SUCCESS_LOGO_SHOP_INSERT, 'success');

			} else {
				@unlink(DIR_FS_CATALOG . 'cache/' . $logo_image->filename);
				$messageStack->add_session(ERROR_LOGO_SHOP_ERROR, 'error');
			}
			xtc_redirect(xtc_href_link('cseo_logo.php'));
            break;
        case 'insert_logo_mail':
			$logo_image = xtc_try_upload('logo_image_mail', DIR_FS_CATALOG . 'cache/');
			if ($logo_image->filename == 'logo.gif') {
				rename(DIR_FS_CATALOG . 'cache/' . $logo_image->filename, DIR_FS_CATALOG . 'templates/' . CURRENT_TEMPLATE . '/img/' . $logo_image->filename);
				@unlink(DIR_FS_CATALOG . 'cache/' . $logo_image->filename);
				$messageStack->add_session(SUCCESS_LOGO_MAIL_INSERT, 'success');

			} else {
				@unlink(DIR_FS_CATALOG . 'cache/' . $logo_image->filename);
				$messageStack->add_session(ERROR_LOGO_MAIL_ERROR, 'error');
			}
			xtc_redirect(xtc_href_link('cseo_logo.php'));
            break;
        case 'insert_logo_pdf':
			$logo_image = xtc_try_upload('logo_image_pdf', DIR_FS_CATALOG . 'cache/');
			if ($logo_image->filename == $pdf_query['pdf_value']) {
				rename(DIR_FS_CATALOG . 'cache/' . $logo_image->filename, DIR_FS_CATALOG . 'templates/' . CURRENT_TEMPLATE . '/img/' . $logo_image->filename);
				@unlink(DIR_FS_CATALOG . 'cache/' . $logo_image->filename);
				$messageStack->add_session(SUCCESS_LOGO_PDF_INSERT, 'success');

			} else {
				@unlink(DIR_FS_CATALOG . 'cache/' . $logo_image->filename);
				$messageStack->add_session(ERROR_LOGO_PDF_ERROR, 'error');
			}
			xtc_redirect(xtc_href_link('cseo_logo.php'));
            break;
    }
}
require(DIR_WS_INCLUDES . 'header.php');
?>

<table border="0" width="100%" cellspacing="2" cellpadding="2">
	<tr>
		<td class="boxCenter" width="100%" valign="top">
			<table border="0" width="100%" cellspacing="0" cellpadding="0">
				<tr>
					<td>
						<div class="pageHeading"><?php echo HEADING_TITLE_LOGO; ?></div>
						<br>

						<form enctype="multipart/form-data" method="post" action="<?php echo xtc_href_link('cseo_logo.php', 'action=insert_logo'); ?>">
						<table border="0" width="100%" cellspacing="0" cellpadding="0" class="dataTableRow">
							<tr>
								<td class="main" valign="top"><?php echo TEXT_IMAGE; ?></td>
								<td class="main"><?php echo '<img src="'.DIR_WS_CATALOG . 'templates/' . CURRENT_TEMPLATE . '/img/logo.png" />'; ?></td>
							</tr>
							<tr>
								<td class="main" valign="top"><?php echo TEXT_IMAGE_NAME; ?></td>
								<td class="main"><?php echo 'templates/' . CURRENT_TEMPLATE . '/img/logo.png'; ?></td>
							</tr>
							<tr>
								<td class="main" valign="top"><?php echo TEXT_IMAGE_UPLOAD; ?></td>
								<td class="main"><?php echo xtc_draw_file_field('logo_image'); ?></td>
							</tr>
							<tr>
								<td class="main" align="left" valign="top" nowrap><?php echo '<input type="submit" class="button" value="' . BUTTON_INSERT . '"/>'; ?></td>
								<td valign="top" class="main">&nbsp;</td>
							</tr>
						</table>
						</form>
					</td>
				</tr>
			</table>
		</td>
	</tr>
</table>

<table border="0" width="100%" cellspacing="2" cellpadding="2">
	<tr>
		<td class="boxCenter" width="100%" valign="top">
			<table border="0" width="100%" cellspacing="0" cellpadding="0">
				<tr>
					<td>
						<div class="pageHeading"><?php echo HEADING_TITLE_LOGO_MAIL; ?></div>
						<br>

						<form enctype="multipart/form-data" method="post" action="<?php echo xtc_href_link('cseo_logo.php', 'action=insert_logo_mail'); ?>">
						<table border="0" width="100%" cellspacing="0" cellpadding="0" class="dataTableRow">
							<tr>
								<td class="main" valign="top"><?php echo TEXT_IMAGE; ?></td>
								<td class="main"><?php echo '<img src="'.DIR_WS_CATALOG . 'templates/' . CURRENT_TEMPLATE . '/img/logo.gif" />'; ?></td>
							</tr>
							<tr>
								<td class="main" valign="top"><?php echo TEXT_IMAGE_NAME; ?></td>
								<td class="main"><?php echo 'templates/' . CURRENT_TEMPLATE . '/img/logo.gif'; ?></td>
							</tr>
							<tr>
								<td class="main" valign="top"><?php echo TEXT_IMAGE_UPLOAD; ?></td>
								<td class="main"><?php echo xtc_draw_file_field('logo_image_mail'); ?></td>
							</tr>
							<tr>
								<td class="main" align="left" valign="top" nowrap><?php echo '<input type="submit" class="button" value="' . BUTTON_INSERT . '"/>'; ?></td>
								<td valign="top" class="main">&nbsp;</td>
							</tr>
						</table>
						</form>
					</td>
				</tr>
			</table>
		</td>
	</tr>
</table>

<table border="0" width="100%" cellspacing="2" cellpadding="2">
	<tr>
		<td class="boxCenter" width="100%" valign="top">
			<table border="0" width="100%" cellspacing="0" cellpadding="0">
				<tr>
					<td>
						<div class="pageHeading"><?php echo HEADING_TITLE_LOGO_PDF; ?></div>
						<br>

						<form enctype="multipart/form-data" method="post" action="<?php echo xtc_href_link('cseo_logo.php', 'action=insert_logo_pdf'); ?>">
						<table border="0" width="100%" cellspacing="0" cellpadding="0" class="dataTableRow">
							<tr>
								<td class="main" valign="top"><?php echo TEXT_IMAGE; ?></td>
								<td class="main"><?php echo '<img src="'.DIR_WS_CATALOG . 'templates/' . CURRENT_TEMPLATE . '/img/' . $pdf_query['pdf_value'] .'" />'; ?></td>
							</tr>
							<tr>
								<td class="main" valign="top"><?php echo TEXT_IMAGE_NAME; ?></td>
								<td class="main"><?php echo CURRENT_TEMPLATE . '/img/' . $pdf_query['pdf_value']; ?></td>
							</tr>
							<tr>
								<td class="main" valign="top"><?php echo TEXT_IMAGE_UPLOAD; ?></td>
								<td class="main"><?php echo xtc_draw_file_field('logo_image_pdf'); ?></td>
							</tr>
							<tr>
								<td class="main" align="left" valign="top" nowrap><?php echo '<input type="submit" class="button" value="' . BUTTON_INSERT . '"/>'; ?></td>
								<td valign="top" class="main">&nbsp;</td>
							</tr>
						</table>
						</form>
					</td>
				</tr>
			</table>
		</td>
	</tr>
</table>

<?php 
require(DIR_WS_INCLUDES . 'footer.php');
require(DIR_WS_INCLUDES . 'application_bottom.php');
